﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;
using KPIS.GERP.GHRMS.DAL;

namespace KPIS.GERP.GHRMS.BLL
{
    public class ActivityRequestBLL
    {
        private static readonly ActivityRequestDAL dal = new ActivityRequestDAL();
        private static readonly TrainingApproveDAL App = new TrainingApproveDAL();
        ConvertNullable cn = new ConvertNullable();

        public DataSet GetActRequest(string act_request_seq, string granted)
        {
            Nullable<int> iact_request_seq = cn.ConvertNullInt(act_request_seq);
            Nullable<int> igranted = cn.ConvertNullInt(granted);
            return dal.GetActRequest(iact_request_seq,igranted);
        }
        public DataSet GetActHistory(string emp_seq)
        {
            Nullable<int> iemp_seq = cn.ConvertNullInt(emp_seq);
            return dal.GetReqStatus(iemp_seq);
        }
        public DataSet GetActRequestUpper(Nullable<int> ActivitySequence, Nullable<int> granted)
        {
            return dal.GetActRequestUpper(ActivitySequence, granted);            
        }
        public DataSet GetReqStatus(string emp_seq)
        {
            Nullable<int> iemp_seq = cn.ConvertNullInt(emp_seq);
            return dal.GetReqStatus(iemp_seq);
        }
        public DataSet GetMsgSend(string send_seq)
        {
            Nullable<int> isend_seq = cn.ConvertNullInt(send_seq);
            return App.GetMsgSend(isend_seq);
        }
        public DataSet LoadActivityRequestForExcel(Nullable<int> ActivitySequence, Nullable<int> granted
            , Nullable<DateTime> ProjectStartDate, Nullable<DateTime> ProjectEndDate)
        {
            return dal.LoadActivityRequestForExcel(ActivitySequence, granted, ProjectStartDate, ProjectEndDate);
        }
        public void InsertActRequest(string act_seq,string emp_seq ,string granted, string remarks, string created_by)
        {
            int iact_seq = Convert.ToInt32(act_seq);
            int iemp_seq = Convert.ToInt32(emp_seq);
            Nullable<int> igranted = cn.ConvertNullInt(granted);
            int icreated_by = Convert.ToInt32(created_by);

            dal.InsertActRequest(iact_seq,iemp_seq, igranted, remarks, icreated_by);
        }
        public void InsertMsgSend(string ref_seq, string ref_type, string send_text, string from_emp_seq
            , string to_emp_seq, string from_send_seq, string remarks, string created_by)
        {
            int iref_seq = Convert.ToInt32(ref_seq);
            int ifrom_emp_seq = Convert.ToInt32(from_emp_seq);
            int ito_emp_seq = Convert.ToInt32(to_emp_seq);
            Nullable<int> ifrom_send_seq = cn.ConvertNullInt(from_send_seq); 
            int icreated_by = Convert.ToInt32(created_by);

            App.InsertMsgSend(iref_seq, ref_type, send_text,ifrom_emp_seq, ito_emp_seq, ifrom_send_seq, remarks, icreated_by);
        }
        public void InsertGranted(string act_request_seq, string granted, string updated_by)
        {
            int iact_request_seq = Convert.ToInt32(act_request_seq);
            Nullable<int> igranted = cn.ConvertNullInt(granted);
            int iupdated_by = Convert.ToInt32(updated_by);
            dal.UpdateActRequest(iact_request_seq,igranted,iupdated_by);
        }
        public void DeleteGranted(string act_request_seq, string granted, string updated_by)
        {
            int iact_request_seq = Convert.ToInt32(act_request_seq);
            Nullable<int> igranted = cn.ConvertNullInt(granted);
            int iupdated_by = Convert.ToInt32(updated_by);
            dal.UpdateActRequest(iact_request_seq, igranted, iupdated_by);
        }
    }
}
